define(function(require){
    var main = require('/static/main.js');
    var m = new main();

    var login = {
        isActive:false,
        init:function(){
            this.bindEvent();
        },
        bindEvent:function(){
            $(document).on("submit","form",function(){
                var JsonData = {
                    Phone : $(".Phone").val().trim(),
                    Password : $(".Password").val().trim()
                }
                $(".btn-purple").html("正在登录...");
                m.ajax(m.baseUrl+'/login/loginin',JsonData,
                    function(ret) {
                        if( ret != null && ret.IsBizSuccess){
                            window.location.href = "/site/index";
                        }else{
                            if(ret != null){
                                $(".pass-msg").html(ret.ErrMsg).show();
                            }else{
                                $(".pass-msg").html('登录失败').show();
                            }

                            $(".btn-purple").html("登录");
                        }

                    });
        });
        }
    }
    login.init();
});
